$('#loady').fadeIn('slow',function(){
	$('#yupoo').empty();

	var apikey="bdda85402c863453487c2a7a61a709fd";

	$.getJSON('http://www.yupoo.com/api/rest/?method=yupoo.interestingness.getList&api_key='+apikey+'&per_page=500&format=json&callback=?',
		function(data){
			var imagearry=data.result.photos.sort(function(){
				return Math.random()>0.5?-1:1;
			});
			var imagelist=imagearry.slice(1,21);
			
			$.each(imagelist, function(i,item){
				var idarrary = item.id.split("-");
				var photoid = idarrary[1];
				var url = 'http://photo' +item.host+ '.yupoo.com/' +item.dir+ '/' +item.filename+ '/square/';
				var dest = 'http://www.yupoo.com/photos/'+item.ownername+'/'+photoid+'/';
				var image = '<a href="'+dest+'" target="_blank"><img src="'+url+'" /></a>';
				
				$('#yupoo').append(image);
				$('#loady').fadeOut('slow',function(){
					$('#yupoo').fadeIn('fast');
			});
			});


		});
	});